package com.qianchang.microfinance.view.findings;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.qianchang.microfinance.R;
import com.qianchang.microfinance.bean.FindsBean;
import com.qianchang.microfinance.view.base.BaseRecyclerAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MFindsAdapter extends BaseRecyclerAdapter<FindsBean>{


    private OnItemClickListener mOnItemClickListener = null;

    public MFindsAdapter(Context context) {
        super(context, BaseRecyclerAdapter.ONLY_FOOTER);
    }



    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_findadapter_layout, parent, false);
        return new ProductHolder(view);
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, FindsBean item, int position) {
        ProductHolder productHolder = (ProductHolder) holder;
        Glide.with(mContext).load(item.getImageUrl()).error(R.drawable.default_img).into(productHolder.titleImg);
        productHolder.tvName.setText(item.getName());
        productHolder.tvExplain.setText(item.getExplain());

    }


    public class ProductHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_ie_id)
        ImageView titleImg;
        @BindView(R.id.tv_explain_id)
        TextView tvExplain;
        @BindView(R.id.tv_name_id)
        TextView tvName;

        public ProductHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }


    public static interface OnItemClickListener {
        void onItemClick(View view, int position);
    }

    public void setOnItemClickListener(OnItemClickListener listener) {
        this.mOnItemClickListener = listener;
    }


}
